<template>
    <el-row class="home" :gutter="20">
        <el-col :span="8" style="margin-top: 20px">
            <el-card shadow="hover">
                <div class="user">
                    <img :src="userImg" />
                    <div class="userinfo">
                        <p class="name">Admin</p>
                        <p class="access">高晶晶</p>
                    </div>
                </div>
                <div class="login-info">
                    <p>上次登录时间 : <span>2022-8-26</span></p>
                </div>
            </el-card>
        </el-col>
        <el-col :span="16">
            <div class="num">
                <el-card>
                <el-card style="margin-top: 20px;height: 460px;">
                    <el-table :data="tableData">
                        <el-table-column v-for="(val,key) in tableLabel" :key="key" :prop="key" :label="val">

                        </el-table-column>
                    </el-table>
                </el-card>
            </el-card>
            </div>
        </el-col>
    </el-row>
</template>
<script>
import { getMenu } from '../../api/data.js'
import { getData } from '../../api/data.js'
export default {
    name: 'home',
    data () {
        return {
            userImg: require('../../src/assets/images/user.jpg'),
            tableData: [
                {
                    name:'软件工程',
                    todayBuy: 10,
                    monthBuy: 100,
                    totalBuy: 400
                },
                {
                    name:'数据结构',
                    todayBuy: 10,
                    monthBuy: 100,
                    totalBuy: 400
                },
                {
                    name:'汇编语言',
                    todayBuy: 10,
                    monthBuy: 100,
                    totalBuy: 400
                }
            ],
            tableLabel: {
                name:'课程',
                    todayBuy: '今日购买量',
                    monthBuy: '该月购买量',
                    totalBuy: '总购买量'

            }
        }
    },
    // mounted() {
    //     this.$http.get('/user?ID=12345')
    // .then(function (response){
    //     console.log(response);
    // })
    // .create(function (error){
    //     console.log(error);
    // });
    // }
    mounted(){
        getMenu().then(res =>{
            console.log(res)
        })
        getData().then(res => {
        const { code,data } = res.data
        if (code === 20000){
            this.tableData = data.tableData
        }
        console.log(res)
        })
    }
}
</script>
